home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / rcs55.zip / RCSBASE.H < prev    next >
C/C++ Source or Header  |  1991-09-15  |  25KB  |  862 lines

  1.  
  2. /*
  3.  *                     RCS common definitions and data structures
  4.  */
  5. #define RCSBASE "$Id: rcsbase.h%v 1.2 1991/08/23 14:40:08 SGP Exp $"
  6.  
  7. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  8.    Copyright 1990 by Paul Eggert
  9.    Distributed under license by the Free Software Foundation, Inc.
  10.  
  11. This file is part of RCS.
  12.  
  13. RCS is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 1, or (at your option)
  16. any later version.
  17.  
  18. RCS is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with RCS; see the file COPYING.  If not, write to
  25. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. Report problems and direct all questions to:
  28.  
  29.     rcs-bugs@cs.purdue.edu
  30.  
  31. */
  32.  
  33.  
  34.  
  35. /*****************************************************************************
  36.  * INSTRUCTIONS:
  37.  * =============
  38.  * See the Makefile for how to define C preprocessor symbols.
  39.  * If you need to change the comment leaders, update the table comtable[]
  40.  * in rcsfnms.c. (This can wait until you know what a comment leader is.)
  41.  *****************************************************************************
  42.  */
  43.  
  44.  
  45. /* $Log: rcsbase.h%v $
  46. # Revision 1.2  1991/08/23  14:40:08  SGP
  47. # Changes made to port to MSDOS environment
  48. #
  49.  * Revision 5.5  1990/12/04  05:18:43  eggert
  50.  * Use -I for prompts and -q for diagnostics.
  51.  *
  52.  * Revision 5.4  1990/11/01  05:03:35  eggert
  53.  * Don't assume that builtins are functions; they may be macros.
  54.  * Permit arbitrary data in logs.
  55.  *
  56.  * Revision 5.3  1990/09/26  23:36:58  eggert
  57.  * Port wait() to non-Posix ANSI C hosts.
  58.  *
  59.  * Revision 5.2  1990/09/04  08:02:20  eggert
  60.  * Don't redefine NAME_MAX, PATH_MAX.
  61.  * Improve incomplete line handling.  Standardize yes-or-no procedure.
  62.  *
  63.  * Revision 5.1  1990/08/29  07:13:53  eggert
  64.  * Add -kkvl.  Fix type typos exposed by porting.  Clean old log messages too.
  65.  *
  66.  * Revision 5.0  1990/08/22  08:12:44  eggert
  67.  * Adjust ANSI C / Posix support.  Add -k, -V, setuid.  Don't call access().
  68.  * Remove compile-time limits; use malloc instead.
  69.  * Ansify and Posixate.  Add support for ISO 8859.
  70.  * Remove snoop and v2 support.
  71.  *
  72.  * Revision 4.9  89/05/01  15:17:14  narten
  73.  * botched previous USG fix 
  74.  * 
  75.  * Revision 4.8  89/05/01  14:53:05  narten
  76.  * changed #include <strings.h> -> string.h for USG systems.
  77.  * 
  78.  * Revision 4.7  88/11/08  15:58:45  narten
  79.  * removed defs for functions loaded from libraries
  80.  * 
  81.  * Revision 4.6  88/08/09  19:12:36  eggert
  82.  * Shrink stdio code size; remove lint; permit -Dhshsize=nn.
  83.  * 
  84.  * Revision 4.5  87/12/18  17:06:41  narten
  85.  * made removed BSD ifdef, now uses V4_2BSD
  86.  * 
  87.  * Revision 4.4  87/10/18  10:29:49  narten
  88.  * Updating version numbers
  89.  * Changes relative to 1.1 are actually relative to 4.2
  90.  * 
  91.  * Revision 1.3  87/09/24  14:02:25  narten
  92.  * changes for lint
  93.  * 
  94.  * Revision 1.2  87/03/27  14:22:02  jenkins
  95.  * Port to suns
  96.  * 
  97.  * Revision 4.2  83/12/20  16:04:20  wft
  98.  * merged 3.6.1.1 and 4.1 (SMALLOG, logsize).
  99.  * moved setting of STRICT_LOCKING to Makefile.
  100.  * changed DOLLAR to UNKN (conflict with KDELIM).
  101.  * 
  102.  * Revision 4.1  83/05/04  09:12:41  wft
  103.  * Added markers Id and RCSfile.
  104.  * Added Dbranch for default branches.
  105.  * 
  106.  * Revision 3.6.1.1  83/12/02  21:56:22  wft
  107.  * Increased logsize, added macro SMALLOG.
  108.  * 
  109.  * Revision 3.6  83/01/15  16:43:28  wft
  110.  * 4.2 prerelease
  111.  * 
  112.  * Revision 3.6  83/01/15  16:43:28  wft
  113.  * Replaced dbm.h with BYTESIZ, fixed definition of rindex().
  114.  * Added variants of NCPFN and NCPPN for bsd 4.2, selected by defining V4_2BSD.
  115.  * Added macro DELNUMFORM to have uniform format for printing delta text nodes.
  116.  * Added macro DELETE to mark deleted deltas.
  117.  *
  118.  * Revision 3.5  82/12/10  12:16:56  wft
  119.  * Added two forms of DATEFORM, one using %02d, the other %.2d.
  120.  *
  121.  * Revision 3.4  82/12/04  20:01:25  wft
  122.  * added LOCKER, Locker, and USG (redefinition of rindex).
  123.  *
  124.  * Revision 3.3  82/12/03  12:22:04  wft
  125.  * Added dbm.h, stdio.h, RCSBASE, RCSSEP, RCSSUF, WORKMODE, TMPFILE3,
  126.  * PRINTDATE, PRINTTIME, map, and ctab; removed Suffix. Redefined keyvallength
  127.  * using NCPPN. Changed putc() to abort on write error.
  128.  *
  129.  * Revision 3.2  82/10/18  15:03:52  wft
  130.  * added macro STRICT_LOCKING, removed RCSUMASK.
  131.  * renamed JOINFILE[1,2] to JOINFIL[1,2].
  132.  *
  133.  * Revision 3.1  82/10/11  19:41:17  wft
  134.  * removed NBPW, NBPC, NCPW.
  135.  * added typdef int void to aid compiling
  136.  */
  137.  
  138. /* GCC */
  139. #if __GNUC__ && !__STRICT_ANSI__
  140. #    define exiting volatile
  141. #else
  142. #    define exiting
  143. #endif
  144.  
  145.  
  146. /* standard include files */
  147.  
  148. #include "conf.h"
  149.  
  150. #if !MAKEDEPEND
  151.  
  152. #include <errno.h>
  153. #include <signal.h>
  154. #include <time.h>
  155.  
  156.  
  157. /* ANSI C library */
  158. /* These declarations are for the benefit of non-ANSI C hosts.  */
  159.  
  160.     /* <errno.h> */
  161. #    ifndef errno
  162.         extern int errno;
  163. #    endif
  164.  
  165.     /* <limits.h> */
  166. #    ifndef CHAR_BIT
  167. #        define CHAR_BIT 8
  168. #    endif
  169. #    ifndef ULONG_MAX
  170. #        define ULONG_MAX (-(unsigned long)1)
  171. #    endif
  172.  
  173.     /* <signal.h> */
  174. #    ifndef signal
  175.         signal_type (*signal P((int,signal_type(*)P((int)))))P((int));
  176. #    endif
  177.  
  178.     /* <stdio.h> */
  179.     /* conf.h declares the troublesome printf family.  */
  180. #    ifndef L_tmpnam
  181. #        define L_tmpnam 25 /* sizeof("/usr/tmp/xxxxxxxxxxxxxxx") */
  182. #    endif
  183. #    ifndef SEEK_SET
  184. #        define SEEK_SET 0
  185. #    endif
  186. #    ifndef fopen
  187.         FILE *fopen P((const char*,const char*));
  188. #    endif
  189. #    ifndef fread
  190.         fread_type fread P((void*,size_t,size_t,FILE*));
  191. #    endif
  192. #    ifndef fwrite
  193.         fread_type fwrite P((const void*,size_t,size_t,FILE*));
  194. #    endif
  195. #    ifndef fclose
  196.         int fclose P((FILE*));
  197. #    endif
  198. #    ifndef fflush
  199.         int fflush P((FILE*));
  200. #    endif
  201. #    ifndef fputs
  202.         int fputs P((const char*,FILE*));
  203. #    endif
  204. #    ifndef fseek
  205.         int fseek P((FILE*,long,int));
  206. #    endif
  207. #    ifndef perror
  208.         void perror P((const char*));
  209. #    endif
  210. #    ifndef clearerr
  211.         void clearerr P((FILE*));
  212. #    endif
  213. #    ifndef feof
  214.         int feof P((FILE*));
  215. #    endif
  216. #    ifndef ferror
  217.         int ferror P((FILE*));
  218. #    endif
  219. #    if has_rename && !defined(rename)
  220.         int rename P((const char*,const char*));
  221. #    endif
  222. #    if has_tmpnam && !defined(tmpnam)
  223.         char *tmpnam P((char*));
  224. #    endif
  225.  
  226.     /* <stdlib.h> */
  227. #    ifndef EXIT_FAILURE
  228. #        define EXIT_FAILURE 1
  229. #    endif
  230. #    ifndef EXIT_SUCCESS
  231. #        define EXIT_SUCCESS 0
  232. #    endif
  233. #    ifndef getenv
  234.         char *getenv P((const char*));
  235. #    endif
  236. #    ifndef exit
  237.         exiting exit_type exit P((int));
  238. #    endif
  239. #    ifndef _exit
  240.         exiting underscore_exit_type _exit P((int));
  241. #    endif
  242. #    ifndef free
  243.         free_type free P((malloc_type));
  244. #    endif
  245. #    ifndef atoi
  246.         int atoi P((const char*));
  247. #    endif
  248. #    ifndef malloc
  249.         malloc_type malloc P((size_t));
  250. #    endif
  251. #    ifndef realloc
  252.         malloc_type realloc P((malloc_type,size_t));
  253. #    endif
  254.  
  255.     /* <string.h> */
  256. #    ifndef strcat
  257.         char *strcat P((char*,const char*));
  258. #    endif
  259. #    ifndef strcpy
  260.         char *strcpy P((char*,const char*));
  261. #    endif
  262. #    ifdef NOTDEF // ifndef strncpy
  263.         char *strncpy P((char*,const char*,int));
  264. #    endif
  265. #    ifndef strrchr
  266.         char *strrchr P((const char*,int));
  267. #    endif
  268. #    ifndef strcmp
  269.         int strcmp P((const char*,const char*));
  270. #    endif
  271. #    ifndef strncmp
  272.         int strncmp P((const char*,const char*,int));
  273. #    endif
  274. #    ifndef strlen
  275.         strlen_type strlen P((const char*));
  276. #    endif
  277.  
  278.     /* <time.h> */
  279. #    ifndef time
  280.         time_t time P((time_t*));
  281. #    endif
  282.  
  283.  
  284. /* Posix 1003.1-1988 */
  285. /* These declarations are for the benefit of non-Posix hosts.  */
  286.  
  287.     /* <limits.h> */
  288. #    if !defined(NAME_MAX) && !defined(_POSIX_NAME_MAX)
  289. #        if has_sys_dir_h
  290. #            include <sys/dir.h>
  291. #        endif
  292. #        ifndef NAME_MAX
  293. #            ifndef MAXNAMLEN
  294. #                define MAXNAMLEN 14
  295. #            endif
  296. #            define NAME_MAX MAXNAMLEN
  297. #        endif
  298. #    endif
  299. #    if !defined(PATH_MAX) && !defined(_POSIX_PATH_MAX)
  300. #        if has_sys_param_h
  301. #            include <sys/param.h>
  302. #        endif
  303. #        ifndef PATH_MAX
  304. #            ifndef MAXPATHLEN
  305. #                define MAXPATHLEN 256
  306. #            endif
  307. #            define PATH_MAX (MAXPATHLEN-1)
  308. #        endif
  309. #    endif
  310.  
  311.     /* <sys/wait.h> */
  312. #    if has_sys_wait_h
  313. #        include <sys/wait.h>
  314. #    endif
  315. #    ifndef WEXITSTATUS
  316. #        define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
  317. #        undef WIFEXITED /* Avoid 4.3BSD incompatibility with Posix.  */
  318. #    endif
  319. #    ifndef WIFEXITED
  320. #        define WIFEXITED(stat_val) (!((stat_val) & 255))
  321. #    endif
  322.  
  323.     /* <fcntl.h> */
  324.     /* conf.h declares fcntl() and open().  */
  325. #    ifdef F_DUPD
  326. #        undef dup2
  327. #        define dup2(a,b) fcntl(a,F_DUPFD,b)
  328. #    else
  329. #        ifndef dup2
  330.             int dup2 P((int,int));
  331. #        endif
  332. #    endif
  333. #    ifdef O_CREAT
  334. #        define open_can_creat 1
  335. #        undef creat
  336. #        define creat(path,mode) open(path,O_CREAT|O_TRUNC|O_WRONLY,mode)
  337. #    else
  338. #        define open_can_creat 0
  339. #        define O_RDONLY 0
  340. #        define O_WRONLY 1
  341. #        define O_CREAT 01000
  342. #        define O_TRUNC 02000
  343. #        ifndef creat
  344.             int creat P((const char*,mode_t));
  345. #        endif
  346. #    endif
  347.  
  348.     /* <stdio.h> */
  349. #    ifndef fdopen
  350.         FILE *fdopen P((int,const char*));
  351. #    endif
  352.  
  353.     /* <sys/stat.h> */
  354.     /* conf.h declares chmod() and umask().  */
  355. #    ifndef S_IRUSR
  356. #        define S_IRUSR 0400
  357. #        define S_IWUSR 0200
  358. #        define S_IRGRP 0040
  359. #        define S_IWGRP 0020
  360. #        define S_IROTH 0004
  361. #        define S_IWOTH 0002
  362. #    endif
  363. #    ifndef S_ISREG
  364. #        define S_ISREG(n) (((n) & S_IFMT) == S_IFREG)
  365. #    endif
  366. #    ifndef fstat
  367.         int fstat P((int,struct stat*));
  368. #    endif
  369. #    ifndef stat
  370.         int stat P((const char*,struct stat*));
  371. #    endif
  372.  
  373.     /* <unistd.h> */
  374. #    ifndef STDIN_FILENO
  375. #        define STDIN_FILENO 0
  376. #        define STDOUT_FILENO 1
  377. #        define STDERR_FILENO 2
  378. #    endif
  379. #    ifndef getlogin
  380.         char *getlogin P((void));
  381. #    endif
  382. #    ifndef _exit
  383.         exiting void _exit P((int));
  384. #    endif
  385. #    ifndef close
  386.         int close P((int));
  387. #    endif
  388. #    ifndef execv
  389.         int execv P((const char*,const char*const*));
  390. #    endif
  391. #    ifndef execvp
  392.         int execvp P((const char*,const char*const*));
  393. #    endif
  394. #    ifndef isatty
  395.         int isatty P((int));
  396. #    endif
  397. #    ifndef read
  398.         int read P((int,char*,unsigned));
  399. #    endif
  400. #    ifdef NOTDEF // ifndef write
  401.         int write P((int,const char*,unsigned));
  402. #    endif
  403. #    ifndef unlink
  404.         int unlink P((const char*));
  405. #    endif
  406. #    if has_getuid
  407. #        ifndef getgid
  408.             gid_t getgid P((void));
  409. #        endif
  410. #        ifndef getuid
  411.             uid_t getuid P((void));
  412. #        endif
  413. #    endif
  414. #    if has_seteuid
  415. #        ifndef setegid
  416.             int setegid P((gid_t));
  417. #        endif
  418. #        ifndef seteuid
  419.             int seteuid P((uid_t));
  420. #        endif
  421. #        ifndef getegid
  422.             gid_t getegid P((void));
  423. #        endif
  424. #        ifndef geteuid
  425.             uid_t geteuid P((void));
  426. #        endif
  427. #    endif
  428. #    if has_vfork
  429. #        ifndef vfork
  430.             pid_t vfork P((void));
  431. #        endif
  432. #    else
  433. #        define vfork fork
  434. #        ifndef fork
  435.             pid_t fork P((void));
  436. #        endif
  437. #    endif
  438. #    if has_getcwd && !defined(getcwd)
  439.         char *getcwd P((char*,size_t));
  440. #    endif
  441.  
  442.  
  443. /* traditional Unix library */
  444. #define EXIT_TROUBLE 2 /* code returned by diff(1) if trouble is found */
  445. #if !has_getcwd && !defined(getwd)
  446.     char *getwd P((char*));
  447. #endif
  448. #if !has_tmpnam && !defined(mktemp)
  449.     char *mktemp P((char*));
  450. #endif
  451. #if !has_sigaction & has_sigblock
  452. #    ifndef sigblock
  453.         int sigblock P((int));
  454. #    endif
  455. #    ifndef sigsetmask
  456.         int sigsetmask P((int));
  457. #    endif
  458. #endif
  459. #ifndef _filbuf
  460.     int _filbuf P((FILE*));
  461. #endif
  462. #ifndef _flsbuf
  463.     int _flsbuf P((int,FILE*));
  464. #endif
  465.  
  466.  
  467. #endif /* !MAKEDEPEND */
  468.  
  469.  
  470. /*
  471.  * Parameters
  472.  */
  473.  
  474. /* backwards compatibility with old versions of RCS */
  475. #define VERSION_MIN 3        /* old output RCS format supported */
  476. #define VERSION_MAX 5        /* newest output RCS format supported */
  477. #ifndef VERSION_DEFAULT        /* default RCS output format */
  478. #    define VERSION_DEFAULT VERSION_MAX
  479. #endif
  480. #define VERSION(n) ((n) - VERSION_DEFAULT) /* internally, 0 is the default */
  481.  
  482. #ifndef STRICT_LOCKING
  483. #define STRICT_LOCKING 1
  484. #endif
  485.                   /* 0 sets the default locking to non-strict;  */
  486.                               /* used in experimental environments.         */
  487.                               /* 1 sets the default locking to strict;      */
  488.                               /* used in production environments.           */
  489.  
  490. #define yearlength       16 /* (good through AD 9,999,999,999,999,999)    */
  491. #define datesize (yearlength+16) /* size of output of DATEFORM            */
  492. #define joinlength         20 /* number of joined revisions permitted       */
  493. #define RCSSUF            'v' /* suffix for RCS files                       */
  494. #define KDELIM            '$' /* delimiter for keywords                     */
  495. #define VDELIM            ':' /* separates keywords from values             */
  496. #define DEFAULTSTATE    "Exp" /* default state of revisions                 */
  497.  
  498.  
  499.  
  500. #define true     1
  501. #define false    0
  502. #define nil      0
  503.  
  504.  
  505.  
  506.  
  507. /* This version of putc prints a char, but aborts on write error            */
  508. #if lint
  509. #    define aputc(c,o) afputc(c,o)
  510. #    define GETC(i,o,c) afputc(c=getc(i), o)
  511. #else
  512. #    define aputc(c,o) do { if (putc(c,o)==EOF) IOerror(); } while(0)
  513. #    define GETC(i,o,c) do {c=getc(i); if (o) aputc(c,o); } while(0)
  514. #endif
  515. /* GETC writes a DEL-character (all ones) on end of file.            */
  516.  
  517. #define WORKMODE(RCSmode, writable) ((RCSmode)&~(S_IWUSR|S_IWGRP|S_IWOTH) | ((writable)?S_IWUSR:0))
  518. /* computes mode of working file: same as RCSmode, but write permission     */
  519. /* determined by writable */
  520.  
  521.  
  522. /* character classes and token codes */
  523. enum tokens {
  524. /* classes */    DELIM,    DIGIT,    IDCHAR,    NEWLN,    LETTER,    Letter,
  525.         PERIOD,    SBEGIN,    SPACE,    UNKN,
  526. /* tokens */    COLON,    EOFILE,    ID,    NUM,    SEMI,    STRING
  527. };
  528.  
  529. #define SDELIM  '@'     /* the actual character is needed for string handling*/
  530. /* SDELIM must be consistent with map[], so that ctab[SDELIM]==SBEGIN.
  531.  * there should be no overlap among SDELIM, KDELIM, and VDELIM
  532.  */
  533.  
  534. #define isdigit(c) ((unsigned)((c)-'0') <= 9) /* faster than ctab[c]==DIGIT */
  535.  
  536.  
  537.  
  538.  
  539.  
  540. /***************************************
  541.  * Data structures for the symbol table
  542.  ***************************************/
  543.  
  544. /* Buffer of arbitrary data */
  545. struct buf {
  546.     char *string;
  547.     size_t size;
  548. };
  549. struct cbuf {
  550.     const char *string;
  551.     size_t size;
  552. };
  553.  
  554. /* Hash table entry */
  555. struct hshentry {
  556.     const char      * num;      /* pointer to revision number (ASCIZ) */
  557.     const char      * date;     /* pointer to date of checkin        */
  558.     const char      * author;   /* login of person checking in        */
  559.     const char      * lockedby; /* who locks the revision             */
  560.     const char      * state;    /* state of revision (Exp by default) */
  561.     struct cbuf        log;      /* log message requested at checkin   */
  562.         struct branchhead * branches; /* list of first revisions on branches*/
  563.     struct cbuf        ig;          /* ignored phrases of revision        */
  564.         struct hshentry   * next;     /* next revision on same branch       */
  565.     struct hshentry   * nexthsh;  /* next revision with same hash value */
  566.     unsigned long        insertlns;/* lines inserted (computed by rlog)  */
  567.     unsigned long        deletelns;/* lines deleted  (computed by rlog)  */
  568.     char            selector; /* true if selected, false if deleted */
  569. };
  570.  
  571. /* list of hash entries */
  572. struct hshentries {
  573.     struct hshentries *rest;
  574.     struct hshentry *first;
  575. };
  576.  
  577. /* list element for branch lists */
  578. struct branchhead {
  579.         struct hshentry   * hsh;
  580.         struct branchhead * nextbranch;
  581. };
  582.  
  583. /* accesslist element */
  584. struct access {
  585.     const char      * login;
  586.         struct access     * nextaccess;
  587. };
  588.  
  589. /* list element for locks  */
  590. struct lock {
  591.     const char      * login;
  592.         struct hshentry   * delta;
  593.         struct lock       * nextlock;
  594. };
  595.  
  596. /* list element for symbolic names */
  597. struct assoc {
  598.     const char      * symbol;
  599.     const char      * num;
  600.         struct assoc      * nextassoc;
  601. };
  602.  
  603.  
  604. #define mainArgs (argc,argv) int argc; char **argv;
  605.  
  606. #if lint
  607. #    define libId(name,rcsid)
  608. #    define mainProg(name,cmd,rcsid) int name mainArgs
  609. #else
  610. #    define libId(name,rcsid) const char name[] = rcsid;
  611. #    define mainProg(name,cmd,rcsid) const char copyright[] = "Copyright 1982,1988,1989 by Walter F. Tichy\nPurdue CS\nCopyright 1990 by Paul Eggert", rcsbaseId[] = RCSBASE, cmdid[] = cmd; libId(name,rcsid) int main mainArgs
  612. #endif
  613.  
  614. /*
  615.  * Markers for keyword expansion (used in co and ident)
  616.  *    Every byte must have class LETTER or Letter.
  617.  */
  618. #define AUTHOR          "Author"
  619. #define DATE            "Date"
  620. #define HEADER          "Header"
  621. #define IDH             "Id"
  622. #define LOCKER          "Locker"
  623. #define LOG             "Log"
  624. #define RCSFILE         "RCSfile"
  625. #define REVISION        "Revision"
  626. #define SOURCE          "Source"
  627. #define STATE           "State"
  628. #define keylength 8 /* max length of any of the above keywords */
  629.  
  630. enum markers { Nomatch, Author, Date, Header, Id,
  631.            Locker, Log, RCSfile, Revision, Source, State };
  632.     /* This must be in the same order as rcskeys.c's Keyword[] array. */
  633.  
  634. #define DELNUMFORM      "\n\n%s\n%s\n"
  635. /* used by putdtext and scanlogtext */
  636.  
  637. /* main program */
  638. extern const char cmdid[];
  639. exiting void exiterr P((void));
  640.  
  641. /* maketime */
  642. void str2date P((const char*,char[datesize]));
  643. void time2date P((time_t,char[datesize]));
  644.  
  645. /* partime */
  646. int partime P((const char*,struct tm*,int*));
  647.  
  648. /* rcsedit */
  649. #define ciklogsize 23 /* sizeof("checked in with -k by ") */
  650. extern FILE *fcopy;
  651. extern const char *resultfile;
  652. extern const char ciklog[ciklogsize];
  653. extern int locker_expansion;
  654. extern struct buf dirtfname[];
  655. #define newRCSfilename (dirtfname[0].string)
  656. FILE *initeditfiles P((const char*));
  657. FILE *rcswriteopen P((const char*));
  658. const char *makedirtemp P((const char*,int));
  659. int expandline P((FILE*,FILE*,const struct hshentry*,int,FILE*));
  660. void arewind P((FILE*));
  661. void copystring P((void));
  662. void dirtempunlink P((void));
  663. void editstring P((const struct hshentry*));
  664. void finishedit P((const struct hshentry*));
  665. void inittmpeditfiles P((void));
  666. void keepdirtemp P((const char*));
  667. void swapeditfiles P((int));
  668. void xpandstring P((const struct hshentry*));
  669.  
  670. /* rcsfnms */
  671. #define bufautobegin(b) ((void) ((b)->size = 0)) /* for auto on block entry */
  672. extern char *workfilename;
  673. extern const char *RCSfilename;
  674. extern int haveworkstat;
  675. extern struct stat RCSstat;
  676. extern struct stat workstat;
  677. FILE *rcsreadopen P((const char*));
  678. char *bufenlarge P((struct buf*,const char**));
  679. char *maketemp P((int));
  680. const char *bindex P((const char*,int));
  681. const char *getfullRCSname P((void));
  682. const char *tmp();
  683. int getfworkstat P((int));
  684. int getworkstat P((void));
  685. int pairfilenames P((int,char**,FILE*(*)P((const char*)),int,int));
  686. void bufalloc P((struct buf*,size_t));
  687. void bufautoend P((struct buf*));
  688. void bufrealloc P((struct buf*,size_t));
  689. void bufscat P((struct buf*,const char*));
  690. void bufscpy P((struct buf*,const char*));
  691. void ffclose P((FILE*));
  692. void tempunlink P((void));
  693. #if has_rename & !bad_rename
  694. #    define re_name(x,y) rename(x,y)
  695. #else
  696.     int re_name P((const char*,const char*));
  697. #endif
  698.  
  699. /* rcsgen */
  700. extern int interactiveflag;
  701. extern struct cbuf curlogmsg;
  702. extern struct buf curlogbuf;
  703. const char *buildrevision P((const struct hshentries*,struct hshentry*,int,int));
  704. int getcstdin P((void));
  705. int ttystdin P((void));
  706. int yesorno P((int,const char*,...));
  707. struct cbuf cleanlogmsg P((char*,size_t));
  708. void putdesc P((int,const char*));
  709.  
  710. /* rcskeys */
  711. extern const char *const Keyword[];
  712. enum markers trymatch P((const char*));
  713.  
  714. /* rcslex */
  715. extern FILE *finptr;
  716. extern FILE *foutptr;
  717. extern FILE *frewrite;
  718. extern const char *NextString;
  719. extern enum tokens nexttok;
  720. extern int hshenter;
  721. extern int nerror;
  722. extern int nextc;
  723. extern int quietflag;
  724. extern unsigned long rcsline;
  725. const char *getid P((void));
  726. exiting void efaterror P((const char*));
  727. exiting void faterror P((const char*,...));
  728. exiting void fatserror P((const char*,...));
  729. exiting void IOerror P((void));
  730. exiting void unterminatedString P((void));
  731. char *checkid P((char*,int));
  732. int getkeyopt P((const char*));
  733. int getlex P((enum tokens));
  734. struct cbuf getphrases P((const char*));
  735. struct cbuf savestring P((struct buf*));
  736. struct hshentry *getnum P((void));
  737. void Lexinit P((void));
  738. void afputc P((int,FILE*));
  739. void aprintf P((FILE*,const char*,...));
  740. void aputs P((const char*,FILE*));
  741. void checksid P((char*));
  742. void diagnose P((const char*,...));
  743. void eflush P((void));
  744. void error P((const char*,...));
  745. void eerror P((const char*));
  746. void fvfprintf P((FILE*,const char*,va_list));
  747. void getkey P((const char*));
  748. void getkeystring P((const char*));
  749. void nextlex P((void));
  750. void oflush P((void));
  751. void printstring P((void));
  752. void readstring P((void));
  753. void redefined P((int));
  754. void warn P((const char*,...));
  755. void warnignore P((void));
  756.  
  757. /* rcsmap */
  758. #define ctab (&map[1])
  759. extern const enum tokens map[];
  760.  
  761. /* rcsrev */
  762. char *partialno P((struct buf*,const char*,unsigned));
  763. int cmpnum P((const char*,const char*));
  764. int cmpnumfld P((const char*,const char*,unsigned));
  765. int compartial P((const char*,const char*,unsigned));
  766. int expandsym P((const char*,struct buf*));
  767. struct hshentry *genrevs P((const char*,const char*,const char*,const char*,struct hshentries**));
  768. unsigned countnumflds P((const char*));
  769. void getbranchno P((const char*,struct buf*));
  770.  
  771. /* rcssyn */
  772. /* These expand modes must agree with Expand_names[] in rcssyn.c.  */
  773. #define KEYVAL_EXPAND 0 /* -kkv `$Keyword: value $' */
  774. #define KEYVALLOCK_EXPAND 1 /* -kkvl `$Keyword: value locker $' */
  775. #define KEY_EXPAND 2 /* -kk `$Keyword$' */
  776. #define VAL_EXPAND 3 /* -kv `value' */
  777. #define OLD_EXPAND 4 /* -ko use old string, omitting expansion */
  778. struct diffcmd {
  779.     unsigned long
  780.         line1, /* number of first line */
  781.         nlines, /* number of lines affected */
  782.         adprev, /* previous 'a' line1+1 or 'd' line1 */
  783.         dafter; /* sum of previous 'd' line1 and previous 'd' nlines */
  784. };
  785. extern const char      * Dbranch;
  786. extern struct access   * AccessList;
  787. extern struct assoc    * Symbols;
  788. extern struct cbuf Comment;
  789. extern struct lock     * Locks;
  790. extern struct hshentry * Head;
  791. extern int         Expand;
  792. extern int               StrictLocks;
  793. extern int               TotalDeltas;
  794. extern const char *const expand_names[];
  795. extern const char Kdesc[];
  796. extern const char Klog[];
  797. extern const char Ktext[];
  798. int getdiffcmd P((FILE*,int,FILE*,struct diffcmd*));
  799. int putdftext P((const char*,struct cbuf,FILE*,FILE*,int));
  800. int putdtext P((const char*,struct cbuf,const char*,FILE*,int));
  801. int str2expmode P((const char*));
  802. void getadmin P((void));
  803. void getdesc P((int));
  804. void gettree P((void));
  805. void ignorephrase P((void));
  806. void initdiffcmd P((struct diffcmd*));
  807. void putadmin P((FILE*));
  808. void puttree P((const struct hshentry*,FILE*));
  809.  
  810. /* rcsutil */
  811. extern int RCSversion;
  812. char *cgetenv P((const char*));
  813. const char *getcaller P((void));
  814. const char *fstrsave P((const char*));
  815. const char *strsave P((const char*));
  816. int addlock P((struct hshentry*));
  817. int addsymbol P((const char*,const char*,int));
  818. int checkaccesslist P((void));
  819. int findlock P((int,struct hshentry**));
  820. int run P((const char*,const char*,...));
  821. int runv P((const char**));
  822. malloc_type fremember P((malloc_type));
  823. malloc_type ftestalloc P((size_t));
  824. malloc_type testalloc P((size_t));
  825. malloc_type testrealloc P((malloc_type,size_t));
  826. #define ftalloc(T) ftnalloc(T,1)
  827. #define talloc(T) tnalloc(T,1)
  828. #if lint
  829.     extern malloc_type lintalloc;
  830. #    define ftnalloc(T,n) (lintalloc = ftestalloc(sizeof(T)*(n)), (T*)0)
  831. #    define tnalloc(T,n) (lintalloc = testalloc(sizeof(T)*(n)), (T*)0)
  832. #    define tfree(p)
  833. #else
  834. #    define ftnalloc(T,n) ((T*) ftestalloc(sizeof(T)*(n)))
  835. #    define tnalloc(T,n) ((T*) testalloc(sizeof(T)*(n)))
  836. #    define tfree(p) free((malloc_type)(p))
  837. #endif
  838. void awrite P((const char*,fread_type,FILE*));
  839. void catchints P((void));
  840. void fastcopy P((FILE*,FILE*));
  841. void ffree P((void));
  842. void ffree1 P((const char*));
  843. void initid P((void));
  844. void ignoreints P((void));
  845. void printdate P((FILE*,const char*,const char*));
  846. void restoreints P((void));
  847. void setRCSversion P((const char*));
  848. #define SETID (has_getuid & has_seteuid & DIFF_PATH_HARDWIRED)
  849. #if has_getuid
  850.     extern uid_t ruid;
  851. #    define myself(u) ((u) == ruid)
  852. #else
  853. #    define myself(u) true
  854. #endif
  855. #if SETID
  856.     void seteid P((void));
  857.     void setrid P((void));
  858. #else
  859. #    define seteid()
  860. #    define setrid()
  861. #endif
  862.